<!--  -->
<template>
  <div>
    <!-- 面包屑 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>评价管理</el-breadcrumb-item>
      <el-breadcrumb-item>评价列表</el-breadcrumb-item>
    </el-breadcrumb>
    <!-- 卡片视图区 -->
    <el-card>
      <el-row :gutter="20">
        <el-col :span="10"
          ><div class="text item">
            <el-input
              placeholder="请输入内容"
              class="input-with-select"
              v-model="queryInfo.query"
              clearable
              @clear="getCommentList"
            >
              <el-button slot="append" icon="el-icon-search"></el-button>
            </el-input></div
        ></el-col>
      </el-row>
      <!-- 评价列表区 -->
      <el-table :data="commentInfo" highlight-current-row border>
        <el-table-column type="index" width="40"> </el-table-column>
        <el-table-column property="commentType" label="评价等级" width="90">
        </el-table-column>
        <el-table-column property="commentTitle" label="商品名" width="150">
          <template slot-scope="scope">
            <div class="commentTitle">{{ scope.row.commentTitle }}</div>
          </template>
        </el-table-column>
        <el-table-column label="评价内容" property="commentContent">
          <template slot-scope="scope">
            <div class="commentContent">{{ scope.row.commentContent }}</div>
          </template>
        </el-table-column>
        <el-table-column property="state" label="评价星级" width="100">
        </el-table-column>
        <el-table-column property="count" label="点赞量" width="70"> </el-table-column>
        <el-table-column property="replyCount" label="回复数" width="70"> </el-table-column>
        <el-table-column property="date" label="评价时间" width="180"> </el-table-column>
        <el-table-column label="操作" width="100">
          <template slot-scope="scope">
            <el-button
              type="primary"
              icon="el-icon-edit"
              @click="showEditDialog(scope.row)"
              >回复</el-button
            >
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="queryInfo.pageNum"
        :page-sizes="[2, 3, 5]"
        :page-size="queryInfo.pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
    <!-- 回复评价对话框 -->
    <el-dialog
      title="回复内容"
      width="50%"
      :visible.sync="dialogEditVisible"
      @close="editDialogClose"
    >
      <el-form
        :model="updateCommentInfo"
        ref="editFormRef"
        label-width="100px"
        class="demo-ruleForm"
      >
      <el-form-item label="评价内容" prop="commentContent">
        <el-input v-model="updateCommentInfo.commentContent" disabled></el-input>
        </el-form-item>
        <el-form-item label="回复消息" prop="replyComment">
          <textarea
            v-model="updateCommentInfo.replyComment"
            class="updateCommentContent"
          ></textarea>
        </el-form-item> 
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="dialogEditVisible = false">取 消</el-button>
        <el-button type="primary" @click="updataCommentInfo">确 定</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
export default {
  name: "Comment",
  data() {
    return {
      queryInfo: {
        query: "",
        // 当前页码
        pageNum: 1,
        // 当前每页显示多少条数据
        pageSize: 2,
      },
      dialogEditVisible: false,
      total: 10,
      // 评价信息
      commentInfo: [
        {
          id: "1",
          commentType: "好评",
          commentTitle: "半袖 特步",
          commentContent: "五星是好评，三四星是中评，二星一下算差评",
          state: "5",
          count: "55",
          replyCount:'1',
          date:"2022-03-05 12:25:55"
        },
      ],
      // 修改信息
      updateCommentInfo: {
        id: "",
        header: "",
        commentType: "",
        commentTitle: "",
        commentContent: "",
        state: "",
        count: "",
        replyCount:'',
        date:"",
        replyComment:''
      },
    };
  },
  created() {
    this.getCommentList();
  },
  methods: {
    // 监听pageSize改变
    handleSizeChange(newSize) {
      // console.log(newSize)
      this.queryInfo.pageSize = newSize;
      this.getUserList();
    },
    // 监听页码值改变事件
    handleCurrentChange(newPage) {
      // console.log(newPage)
      this.queryInfo.pageNum = newPage;
      this.getUserList();
    },
    // 获取评价列表
    getCommentList() {},
    // 回复评价信息
    updataCommentInfo() {
      this.dialogEditVisible = false;
    },
    // 修改对话框显示
    showEditDialog(row) {
      this.dialogEditVisible = true;
      this.updateCommentInfo = row;

    },
    // 关闭修改对话框
    editDialogClose() {
      this.$refs.editFormRef.resetFields();
    },
    
  },
};
</script>
<style lang="less" scoped>
.headimag {
  height: 90px;
  width: 90px;
}
.updateCommentContent {
  width: 530px;
}
.commentContent,
.commentTitle {
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}
</style>
